#include "widget.h"
#include "ui_widget.h"

#include <QDialog>
#include <QPushButton>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    // 复合选择器
//    this->setStyleSheet("QDialog > QPushButton {"
//                        " color: red;"
//                        "}");

//    this->setStyleSheet("QPushButton, QLabel {"
//                        " color: #AA0066;"
//                        "}");

//    connect(ui->pushButton, &QPushButton::clicked, [this](){
//        QDialog * dia = new QDialog(this);
//        dia->resize(400, 200);

//        QPushButton *btn = new QPushButton("按钮", dia);
//        btn->move(20, 20);

//        dia->show();
//    });

    // 子控件
//    this->setStyleSheet("QComboBox::down-arrow {"
//                        " image: url(:/images/arrow.png);"
//                        "}");

    // QProgressBar：选中进度条部件，设置它的基本样式
    // QProgressBar::chunk  ：设置已完成部分的样式
//    this->setStyleSheet("QProgressBar {"
//                        " font: 900 normal 16px '微软雅黑';"
//                        " color: red;"
//                        " text-align: center center;"
//                        "}"
//                        "QProgressBar::chunk {"
//                        " background-color: #05B8CC;"
//                        " width: 20px;"
//                        " margin: 0.5px;"
//                        "}");

    this->setStyleSheet("QCheckBox {"
                        " font: 18px '微软雅黑';"
                        " color: #87AB12;"
                        " spacing: 5px;"
                        "}"
                        "QCheckBox::indicator {"
                        " width: 15px;"
                        " height: 15px;"
                        " background-color: #666;"
                        "}"
                        "QCheckBox::indicator:unchecked {"
                        " background-color: #666;"
                        "}"
                        "QCheckBox::indicator:unchecked:hover {"
                        " background-color: pink;"
                        "}"
                        "QCheckBox::indicator:checked {"
                        " image: url(:/images/right.png)"
                        "}");

    // 伪状态
//    ui->pushButton->setStyleSheet("QPushButton:hover {"
//                                  " color: red;"
//                                  " text-decoration: underline;"
//                                  "}");

}

Widget::~Widget()
{
    delete ui;
}
